package com.allwees.bs.c.module.user.entity;

import com.allwees.bs.c.module.ops.entity.CashActiveDefEntity;
import com.allwees.bs.core.model.user.entity.UserCashLogDefModel;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.NoArgsConstructor;

import javax.persistence.Entity;
import javax.persistence.Table;
import javax.persistence.Transient;

@Data
@EqualsAndHashCode(callSuper = true)
@NoArgsConstructor
@Entity()
@Table(name = "usr_account_cash_log")
public class UserCashLogEntity extends UserCashLogDefModel {

    @Transient
    private String firstName;

    @Transient
    private String lastName;

    public void setUser(UserEntity user) {
        if (user == null) {
            return;
        }
        this.firstName = user.getFirstName();
        this.lastName = user.getLastName();
    }

    public UserCashLogEntity(CashActiveDefEntity cashActiveDef) {
        this.value = cashActiveDef.getValue();
        this.cashActiveUuid = cashActiveDef.getUuid();
    }
}
